//
//  RW_RemoveView.m
//  SleepApp
//
//  Created by chuangqi on 2021/4/9.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_RemoveView.h"
#import "RW_UserSingleItemViewCell.h"
#import "RW_UserSingleListItemCell.h"

@interface RW_RemoveView (){
    id _data;
}
/** 标题内容 */
@property (nonatomic,strong) UILabel *wlclass_title_label;
/** 取消 */
@property (nonatomic,strong) UIButton *wlclass_close_button;
/** 确定 */
@property (nonatomic,strong) UIButton *wlclass_sure_button;
@end

@implementation RW_RemoveView

#pragma mark -- 视图初始化 必须实现
/** 初始化视图数据 */
-(void)initView{
    self.backgroundColor = UIColor.whiteColor;


    self.layer.shadowOpacity = 0.2f;
    self.layer.shadowRadius = 5.f;
    self.layer.shadowOffset = CGSizeMake(0,0);
    self.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.3f].CGColor;
    self.layer.cornerRadius = 8;
    self.clipsToBounds = YES;
    
    [self.contentView addSubview:self.wlclass_close_button];
    [self.contentView addSubview:self.wlclass_sure_button];
    [self.contentView addSubview:self.wlclass_title_label];
    
    [self.wlclass_title_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self).mas_offset(-20);
        make.right.mas_equalTo(self.contentView).mas_offset(-15);
        make.left.mas_equalTo(self.contentView).mas_offset(15);
    }];
    [self.wlclass_close_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.mas_equalTo(self.contentView);
        make.height.mas_offset(45);
    }];
    [self.wlclass_sure_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.mas_equalTo(self.contentView);
        make.left.mas_equalTo(self.wlclass_close_button.mas_right);
        make.width.mas_equalTo(self.wlclass_close_button);
        make.height.mas_equalTo(self.wlclass_close_button);
    }];
}
/** 初始化视图数据 */
-(void)initData:(NSArray *)dataList{
    for (id data in dataList) {
        if ([data isKindOfClass:RW_UserSingleItemViewCellModel.class]){
            _data = data;
            RW_UserSingleItemViewCellModel *model = data;
            self.wlclass_title_label.text = [NSString stringWithFormat:@"确认移除歌单“%@”",model.title_string];
            break;
        } else if ([data isKindOfClass:RW_UserSingleListItemCellModel.class]){
            _data = data;
            RW_UserSingleListItemCellModel *model = data;
            self.wlclass_title_label.text = [NSString stringWithFormat:@"确认移除收藏的歌曲“%@”",model.title_string];
            break;
        }
    }
}
#pragma mark -- Base代理
/**
 可选
 视图弹出方向
 */
-(Base_General_Show_type)showViewLocation{
    return Base_General_Show_type_Botton;
}
/**
 可选
 是否需要处理点击确定后的操作逻辑
 点击确认按钮的 选中数据操作。
 需要子试图调用 defaultSureCloseViewData: 方法
 会回调 closeBlock_wl 的block块，内容为操作完毕后的内容
 默认回调 closeBlock_wl，无参数
 */
-(void)clickSelectCloseViewData:(id)data sureBlock:(void(^)(id data))sureBlock{
    if (sureBlock){
        sureBlock(data);
    }
}

/**
 可选
 初始化展示视图约束
 默认的大小为屏幕高度一半，底部贴合
 */
-(void)initViewMakeConstraints:(MASConstraintMaker *)make fromView:(UIView *)fromView{
    make.center.mas_equalTo(fromView);
    make.height.mas_offset(140);
    make.width.mas_equalTo(fromView).multipliedBy(.8f);
}

#pragma mark -- 操作
-(void)click_sure_button:(UIButton *)sender{
    [self defaultSureCloseViewData:_data];
}


#pragma mark -- 懒加载
-(UIButton *)wlclass_sure_button{
    if (!_wlclass_sure_button){
        _wlclass_sure_button = [[UIButton alloc]init];
        [_wlclass_sure_button setTitle:@"确定" forState:UIControlStateNormal];
        [_wlclass_sure_button setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
        [_wlclass_sure_button addTarget:self action:@selector(click_sure_button:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _wlclass_sure_button;
}
-(UIButton *)wlclass_close_button{
    if (!_wlclass_close_button){
        _wlclass_close_button = [[UIButton alloc]init];
        [_wlclass_close_button setTitle:@"取消" forState:UIControlStateNormal];
        [_wlclass_close_button setTitleColor:UIColor.blackColor forState:UIControlStateNormal];
        [_wlclass_close_button addTarget:self action:@selector(defaultCloseView) forControlEvents:UIControlEventTouchUpInside];
    }
    return _wlclass_close_button;
}
-(UILabel *)wlclass_title_label{
    if (!_wlclass_title_label){
        _wlclass_title_label = [[UILabel alloc]init];
        _wlclass_title_label.numberOfLines = 3;
        _wlclass_title_label.textAlignment = NSTextAlignmentCenter;
    }
    return _wlclass_title_label;
}
@end
